package customer;

import java.util.Scanner;

public class CustomerExceptionDemo {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入一个正整数：");
        try {
            int num1 = scanner.nextInt();
            if (num1 < 0) {
                throw new MyException("错误！输入数据为负数。");
            }

        } catch (MyException e) {
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
